package com.glorysoft.knowlespda.model
import com.glorysoft.knowlespda.base.BaseRepository
import com.glorysoft.knowlespda.base.Constant
import com.glorysoft.knowlespda.entity.AuthEntity
import com.glorysoft.knowlespda.entity.LoginEntity
import com.glorysoft.knowlespda.entity.PairingEntity
import com.google.gson.JsonObject
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse


/**
 * FileName: LoginRepository
 * Author: XJH
 * Date: 2021/5/24 17:11
 * Description:
 * History:
 */
class PairRepository : BaseRepository() {

    suspend fun getAuthority(map: JsonObject): PairingEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"Authority"))
            .toResponse<PairingEntity>()
            .await()


    }

    suspend fun unPair(map: JsonObject): PairingEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"UnPair"))
            .toResponse<PairingEntity>()
            .await()


    }

    suspend fun pairMachine(map: JsonObject): PairingEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"PairMachine"))
            .toResponse<PairingEntity>()
            .await()


    }

    suspend fun getPdaAuthInfo(map: JsonObject): AuthEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"GetPDAsAuthInfo"))
            .toResponse<AuthEntity>()
            .await()


    }

    suspend fun updatePdaAuthInfo(map: JsonObject): AuthEntity {
        return RxHttp.postForm(Constant.REQUEST_URL_DEBUG)
            .addAll(getInJsonData(map,"PDAsAuthInfoUpdate"))
            .toResponse<AuthEntity>()
            .await()


    }
}